const options = {
    moduleCache: {
        vue: Vue
    },
    getFile(url) {
        url = /.*?\.js|.mjs|.css|.less|.vue$/.test(url) ? url : `${url}.vue`
        const type = /.*?\.js|.mjs$/.test(url) ? ".mjs" : /.*?\.vue$/.test(url) ? '.vue' : /.*?\.css$/.test(url) ? '.css' : '.vue';
        const getContentData = asBinary => fetch(url).then(res => !res.ok ? Promise.reject(url) : asBinary ? res.arrayBuffer() : res.text())
        return {getContentData: getContentData, type: type}
    },
    addStyle(textContent) {
        let styleElement = document.createElement('style');
        document.head.insertBefore(Object.assign(styleElement, {textContent}),
            document.head.getElementsByTagName('style')[0] || null);
    },
    handleModule(type, getContentData, path, options) {
        switch (type) {
            case '.css':
                return options.addStyle(getContentData(false));
            case '.less':
                console.error('.......')
        }
    },
    log(type, ...args) {
        console.log(type, ...args);
    }
};

const { loadModule, vueVersion } = window['vue2-sfc-loader'];

loadModule('./App.vue', options).then(component => {
  new Vue(component).$mount('#app');
})


